package com.brainardphotography.blog.web.admin;

import java.util.List;

import com.brainardphotography.blog.BlogEntry;
import com.brainardphotography.blog.dao.BlogEntryDAO;
import com.google.inject.Inject;
import com.google.sitebricks.At;
import com.google.sitebricks.http.Get;

@At("/admin")
public class Admin extends AdminBrick {
	private static final long serialVersionUID = -6063161082143405441L;

	private BlogEntryDAO blogEntryDAO;
	
	public Admin() {
	}

	@Inject
	public void setBlogEntryDAO(BlogEntryDAO blogEntryDAO) {
		this.blogEntryDAO = blogEntryDAO;
	}

	@Get
	public String get() {
		if(! getAdminUser()) {
			return "/";
		}
		
		return null;
	}

	public List<BlogEntry> getBlogEntries() {
		return blogEntryDAO.findAll();
	}
	
}
